package com.winning.devops.demo.model;

import com.fasterxml.jackson.annotation.JsonView;
import com.winning.devops.demo.annotation.TestConstraint;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import java.util.Date;

/**
 * @author chensj
 * @title
 * @project winning-spring-security
 * @package com.winning.devops.demo.model
 * @date: 2019-05-09 22:13
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {

    @JsonView(UserSimpleView.class)
    private Long id;
    @JsonView(UserSimpleView.class)
    @TestConstraint
    private String name;
    @JsonView(UserDetailView.class)
    @NotBlank(message = "密码不能为空")
    private String password;
    @JsonView(UserSimpleView.class)
    @Past(message = "出生日期必须是过去的日期")
    private Date birthday;

    /**
     * 信息展示简单视图
     */
    public interface UserSimpleView{};

    /**
     * 信息展示全量视图 继承于简单视图
     */
    public interface UserDetailView extends UserSimpleView{};
}
